package com.zero.studentsystem;

import java.util.ArrayList;
import java.util.Random;

public class Test {
    public static void main(String[] args) {
        ArrayList<Character> list = new ArrayList<>();
        for (int i = 0; i < 26; i++) {
            list.add((char) ('a' + i));
            list.add((char) ('A' + i));
        }

        StringBuilder sb = new StringBuilder();
        Random r = new Random();
        for (int i = 0; i < 4; i++) {
            int index = r.nextInt(list.size());
            char c = list.get(index);
            sb.append(c);
        }

        int number = r.nextInt(10);
        sb.append(number);

        char[] chs = sb.toString().toCharArray();
        int randomIndex = r.nextInt(chs.length);

        char temp = chs[randomIndex];
        chs[randomIndex] = chs[chs.length-1];
        chs[chs.length-1] = temp;

        String getCode = new String(chs);

        System.out.println("验证码");
        System.out.println(getCode);

    }
}
